package com.xjoyt.pay.commons;

import java.text.ParseException;
import java.util.Date;

import org.apache.commons.lang.time.DateFormatUtils;

import com.xjoyt.pay.constants.DateConstant;

/**
 * 日期工具类
 * 
 * @author Administrator
 *
 */
public final class DateUtils {

	public   static Date toStartDate(Date date) {
		try {
			return org.apache.commons.lang.time.DateUtils.parseDate(
					DateFormatUtils.format(date, DateConstant.DATE_FORMAT_PATTERN), DateConstant.DATE_PARSE_PATTERNS);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}

	public Date toEndDate(Date date) {
		try {
			return org.apache.commons.lang.time.DateUtils.parseDate(
					DateFormatUtils.format(date, DateConstant.DATE_FORMAT_PATTERN) + " 23:59:59",
					DateConstant.DATE_PARSE_PATTERNS);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}
}
